{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "professional-composer",
   "metadata": {},
   "source": [
    "# A half cell model"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "naval-management",
   "metadata": {},
   "source": [
    "In the [previous notebook](./4-comparing-full-and-reduced-order-models.ipynb) we saw how to compare full and reduced-order models. Both of these models were posed on a single domain: the negative electrode particle. Here we will see how to create a model which contains multiple domains.\n",
    "\n",
    "We consider a problem posed on a half-cell geometry, which consists of a separator ($-L_s<x<0$) and a positive electrode ($0<x<L_p$). These two regions are considered \"macroscale\" domains. At each point in the positive electrode we treat a \"microscale\" problem to model diffusion of lithium within the positive particles ($0<r<R_p$). We will see how to create variables in each of the different domains so that the governing equations are properly coupled. \n",
    "\n",
    "In the interest of simplicity we assume that the current in both the the solid and electrolyte is given by Ohm's law, and ignore any concentration gradients in the electrolyte. The governing equations for charge conservation at the macroscale are then \n",
    "$$\n",
    "i_e = -\\kappa \\nabla \\phi_e, \\quad \\nabla i_e = a j, \\quad -L_s<x<0, \\\\\n",
    "i = -\\sigma \\nabla \\phi, \\quad \\nabla \\cdot i = -a j, \\quad 0<x<L_p,\n",
    "$$\n",
    "where $i$ and $i_e$ are the current densities in the solid and electrolyte, respectively, $\\phi$ and $\\phi_e$ are the electric potentials in the solid and electrolyte, respectively, $\\sigma$ is the solid conductivity, $\\kappa$ is the ionic conductivity, $a$ is the electrode surface area per unit volume and $j$ the interfacial current density. The charge conservation equations are subject to the boundary conditions \n",
    "$$\n",
    "\\left.\\phi_e\\right\\vert_{x=-L_s} = 0, \\quad \\left.i_e\\right\\vert_{x=L_p} = 0, \\quad \\left.i\\right\\vert_{x=0} = 0, \\quad \\left.i\\right\\vert_{x=L_p} = \\frac{I_{\\text{app}}}{A},\n",
    "$$\n",
    "where $I_{\\text{app}}$ is the applied current and $A$ is the electrode cross-sectional area. We then have an equation posed at each macroscopic point in the electrode ($0<x<L_p$) describing transport of lithium within the active material particles. That is,\n",
    "$$\n",
    "  \\frac{\\partial c}{\\partial t} = \\nabla \\cdot (D \\nabla c), \\quad 0<r<R_p,\n",
    "$$\n",
    "with the following boundary and initial conditions:\n",
    "$$\n",
    "  \\left.\\frac{\\partial c}{\\partial r}\\right\\vert_{r=0} = 0, \\quad \\left.\\frac{\\partial c}{\\partial r}\\right\\vert_{r=R} = -\\frac{j}{FD}, \\quad \\left.c\\right\\vert_{t=0} = c_0,\n",
    "$$\n",
    "where $c$ is the concentration, $r$ the radial coordinate, $t$ time, $R$ the particle radius, $D$ the diffusion coefficient, $F$ Faraday's constant, and $c_0$ the initial concentration. For the interfacial current density we assume Butler-Volmer kinetics\n",
    "$$\n",
    "j = \\begin{cases}\n",
    "        0 &-L_s<x<0 \\\\\n",
    "        2 j_0(c)\\sinh\\left(\\frac{F}{2RT}(\\phi-\\phi_e-U(c))\\right) &0<x<L_p\n",
    "    \\end{cases},\n",
    "$$\n",
    "where $j_0$ is the exchange current density, and $U$ is the open-circuit potential."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "remarkable-version",
   "metadata": {},
   "source": [
    "## Setting up the model\n",
    "As before, we begin by importing the PyBaMM library into this notebook, along with any other packages we require, and start with an empty `pybamm.BaseModel`\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "short-tension",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "%pip install \"pybamm[plot,cite]\" -q    # install PyBaMM if it is not installed\n",
    "import pybamm\n",
    "\n",
    "model = pybamm.BaseModel()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "white-presentation",
   "metadata": {},
   "source": [
    "Let's first define our model variables. We can define the electric potential in the positive electrode in the same way as we defined the concentration variables in the previous notebooks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "catholic-condition",
   "metadata": {},
   "outputs": [],
   "source": [
    "phi = pybamm.Variable(\"Positive electrode potential [V]\", domain=\"positive electrode\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "academic-pittsburgh",
   "metadata": {},
   "source": [
    "The potential in the electrolyte spans two domains. To set this up we first define the electric potential in each of the domains"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "compound-equity",
   "metadata": {},
   "outputs": [],
   "source": [
    "phi_e_s = pybamm.Variable(\"Separator electrolyte potential [V]\", domain=\"separator\")\n",
    "phi_e_p = pybamm.Variable(\n",
    "    \"Positive electrolyte potential [V]\", domain=\"positive electrode\"\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "legislative-firmware",
   "metadata": {},
   "source": [
    "and then concatenate these two variables together to define a single variable that spans the separator and positive electrode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "square-brief",
   "metadata": {},
   "outputs": [],
   "source": [
    "phi_e = pybamm.concatenation(phi_e_s, phi_e_p)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "inappropriate-pizza",
   "metadata": {},
   "source": [
    "Note that in our formulation the separator will be on the left and the positive electrode will be on the right, so this is the order in which we concatenated the variables for the electrolyte potential in each domain."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "freelance-gilbert",
   "metadata": {},
   "source": [
    "The concentration in the electrode particles can vary both in $r$ and $x$, but diffusion only occurs in the $r$ direction. In order to handle this situation we introduce the concept of \"auxiliary domains\". These are domains in which quantities can vary, but spatial operators do not act. To set up our concentration variable we create a `Variable` which has domain \"positive particle\" and secondary domain \"positive electrode\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "sealed-catholic",
   "metadata": {},
   "outputs": [],
   "source": [
    "c = pybamm.Variable(\n",
    "    \"Positive particle concentration [mol.m-3]\",\n",
    "    domain=\"positive particle\",\n",
    "    auxiliary_domains={\n",
    "        \"secondary\": \"positive electrode\",\n",
    "    },\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "proved-watch",
   "metadata": {},
   "source": [
    "Now spatial operators acting on `c` only act in the $r$ direction (corresponding to the primary domain \"positive particle\"), but `c` can still depend on $x$ (corresponding to the secondary domain  \"positive electrode\"). For more details on the different domains (primary, secondary, etc.) see the [broadcasts notebook](../expression_tree/broadcasts.ipynb)."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "sustained-strap",
   "metadata": {},
   "source": [
    "Next we will define our parameters. As seen before, scalar parameters can be defined using the `Parameter` object "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "legendary-cycling",
   "metadata": {},
   "outputs": [],
   "source": [
    "F = pybamm.Parameter(\"Faraday constant [C.mol-1]\")\n",
    "R = pybamm.Parameter(\"Molar gas constant [J.mol-1.K-1]\")\n",
    "T = pybamm.Parameter(\"Temperature [K]\")\n",
    "\n",
    "a = pybamm.Parameter(\"Surface area per unit volume [m-1]\")\n",
    "R_p = pybamm.Parameter(\"Positive particle radius [m]\")\n",
    "L_s = pybamm.Parameter(\"Separator thickness [m]\")\n",
    "L_p = pybamm.Parameter(\"Positive electrode thickness [m]\")\n",
    "A = pybamm.Parameter(\"Electrode cross-sectional area [m2]\")\n",
    "\n",
    "sigma = pybamm.Parameter(\"Positive electrode conductivity [S.m-1]\")\n",
    "kappa = pybamm.Parameter(\"Electrolyte conductivity [S.m-1]\")\n",
    "D = pybamm.Parameter(\"Diffusion coefficient [m2.s-1]\")\n",
    "\n",
    "I_app = pybamm.Parameter(\"Applied current [A]\")\n",
    "c0 = pybamm.Parameter(\"Initial concentration [mol.m-3]\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "focal-pipeline",
   "metadata": {},
   "source": [
    "Parameters can also have some functional dependence. We can define such parameters using the `FunctionParameter` object. We also need to specify the inputs (i.e. the variables on which the function depends). In our example both the exchange current density and the open-circuit potential will depend on the particle surface concentration."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "valuable-graphics",
   "metadata": {},
   "outputs": [],
   "source": [
    "c_surf = pybamm.surf(c)  # get the surface concentration\n",
    "inputs = {\"Positive particle surface concentration [mol.m-3]\": c_surf}\n",
    "j0 = pybamm.FunctionParameter(\n",
    "    \"Positive electrode exchange-current density [A.m-2]\", inputs\n",
    ")\n",
    "U = pybamm.FunctionParameter(\"Positive electrode OCP [V]\", inputs)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "impressive-grill",
   "metadata": {},
   "source": [
    "We also need to define the interfacial current, which is zero in the separator and given by the Butler-Volmer equation in the positive electrode"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "chicken-sweden",
   "metadata": {},
   "outputs": [],
   "source": [
    "j_s = pybamm.PrimaryBroadcast(0, \"separator\")\n",
    "j_p = 2 * j0 * pybamm.sinh((F / 2 / R / T) * (phi - phi_e_p - U))\n",
    "j = pybamm.concatenation(j_s, j_p)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "proud-vancouver",
   "metadata": {},
   "source": [
    "Now we can write our governing equations, boundary and initial conditions. Note that we provide initial conditions for the algebraic equations. These are not really initial conditions, but are used as an initial guess for the solver."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "asian-wesley",
   "metadata": {},
   "outputs": [],
   "source": [
    "# charge conservation equations\n",
    "i = -sigma * pybamm.grad(phi)\n",
    "i_e = -kappa * pybamm.grad(phi_e)\n",
    "model.algebraic = {\n",
    "    phi: pybamm.div(i) + a * j_p,\n",
    "    phi_e: pybamm.div(i_e) - a * j,\n",
    "}\n",
    "# particle equations (mass conservation)\n",
    "N = -D * pybamm.grad(c)  # flux\n",
    "dcdt = -pybamm.div(N)\n",
    "model.rhs = {c: dcdt}\n",
    "\n",
    "# boundary conditions\n",
    "model.boundary_conditions = {\n",
    "    phi: {\n",
    "        \"left\": (pybamm.Scalar(0), \"Neumann\"),\n",
    "        \"right\": (-I_app / A / sigma, \"Neumann\"),\n",
    "    },\n",
    "    phi_e: {\n",
    "        \"left\": (pybamm.Scalar(0), \"Dirichlet\"),\n",
    "        \"right\": (pybamm.Scalar(0), \"Neumann\"),\n",
    "    },\n",
    "    c: {\"left\": (pybamm.Scalar(0), \"Neumann\"), \"right\": (-j_p / F / D, \"Neumann\")},\n",
    "}\n",
    "\n",
    "# initial conditions\n",
    "inputs = {\"Initial concentration [mol.m-3]\": c0}\n",
    "U_init = pybamm.FunctionParameter(\"Positive electrode OCP [V]\", inputs)\n",
    "model.initial_conditions = {phi: U_init, phi_e: 0, c: c0}"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "starting-pulse",
   "metadata": {},
   "source": [
    "Finally we can add any variables of interest to the model "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "certified-species",
   "metadata": {},
   "outputs": [],
   "source": [
    "model.variables = {\n",
    "    \"Positive electrode potential [V]\": phi,\n",
    "    \"Electrolyte potential [V]\": phi_e,\n",
    "    \"Positive particle concentration [mol.m-3]\": c,\n",
    "    \"Positive particle surface concentration [mol.m-3]\": c_surf,\n",
    "    \"Average positive particle surface concentration [mol.m-3]\": pybamm.x_average(\n",
    "        c_surf\n",
    "    ),\n",
    "    \"Positive electrode interfacial current density [A.m-2]\": j_p,\n",
    "    \"Positive electrode OCP [V]\": pybamm.boundary_value(U, \"right\"),\n",
    "    \"Voltage [V]\": pybamm.boundary_value(phi, \"right\"),\n",
    "}"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "global-costs",
   "metadata": {},
   "source": [
    "## Using the model"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "elementary-mouse",
   "metadata": {},
   "source": [
    "As we have seen before, we can provide values for our parameters using the `ParameterValues` class. As well as providing scalar values, we also need to provide the functional form using by our `FunctionParameter` objects. Here we will define these functions locally, but we could provide the path to a function defined elsewhere or provide data (see the  [parameterization notebook](../parameterization/parameterization.ipynb))."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "joint-dover",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pybamm import tanh\n",
    "\n",
    "# both functions will depend on the maximum concentration\n",
    "c_max = pybamm.Parameter(\"Maximum concentration in positive electrode [mol.m-3]\")\n",
    "\n",
    "\n",
    "def exchange_current_density(c_surf):\n",
    "    k = 6 * 10 ** (-7)  # reaction rate [(A/m2)(m3/mol)**1.5]\n",
    "    c_e = 1000  # (constant) electrolyte concentration [mol.m-3]\n",
    "    return k * c_e**0.5 * c_surf**0.5 * (c_max - c_surf) ** 0.5\n",
    "\n",
    "\n",
    "def open_circuit_potential(c_surf):\n",
    "    stretch = 1.062\n",
    "    sto = stretch * c_surf / c_max\n",
    "\n",
    "    u_eq = (\n",
    "        2.16216\n",
    "        + 0.07645 * tanh(30.834 - 54.4806 * sto)\n",
    "        + 2.1581 * tanh(52.294 - 50.294 * sto)\n",
    "        - 0.14169 * tanh(11.0923 - 19.8543 * sto)\n",
    "        + 0.2051 * tanh(1.4684 - 5.4888 * sto)\n",
    "        + 0.2531 * tanh((-sto + 0.56478) / 0.1316)\n",
    "        - 0.02167 * tanh((sto - 0.525) / 0.006)\n",
    "    )\n",
    "    return u_eq"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "pressed-algeria",
   "metadata": {},
   "source": [
    "Now we can pass these functions, along with our scalar parameters, to `ParameterValues`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "metric-wrong",
   "metadata": {},
   "outputs": [],
   "source": [
    "param = pybamm.ParameterValues(\n",
    "    {\n",
    "        \"Surface area per unit volume [m-1]\": 0.15e6,\n",
    "        \"Positive particle radius [m]\": 10e-6,\n",
    "        \"Separator thickness [m]\": 25e-6,\n",
    "        \"Positive electrode thickness [m]\": 100e-6,\n",
    "        \"Electrode cross-sectional area [m2]\": 2.8e-2,\n",
    "        \"Applied current [A]\": 0.9,\n",
    "        \"Positive electrode conductivity [S.m-1]\": 10,\n",
    "        \"Electrolyte conductivity [S.m-1]\": 1,\n",
    "        \"Diffusion coefficient [m2.s-1]\": 1e-13,\n",
    "        \"Faraday constant [C.mol-1]\": 96485,\n",
    "        \"Initial concentration [mol.m-3]\": 25370,\n",
    "        \"Molar gas constant [J.mol-1.K-1]\": 8.314,\n",
    "        \"Temperature [K]\": 298.15,\n",
    "        \"Maximum concentration in positive electrode [mol.m-3]\": 51217,\n",
    "        \"Positive electrode exchange-current density [A.m-2]\": exchange_current_density,\n",
    "        \"Positive electrode OCP [V]\": open_circuit_potential,\n",
    "    }\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "timely-temple",
   "metadata": {},
   "source": [
    "Next we define the geometry. In the same way that our variable for the concentration in the electrode particles had and \"auxiliary domain\", our spatial variable $r$ also has an auxiliary domain. This means that when the model in discretised there will be the correct number of particles included in the geometry - one for each point in $x$."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "industrial-stable",
   "metadata": {},
   "outputs": [],
   "source": [
    "r = pybamm.SpatialVariable(\n",
    "    \"r\",\n",
    "    domain=[\"positive particle\"],\n",
    "    auxiliary_domains={\"secondary\": \"positive electrode\"},\n",
    "    coord_sys=\"spherical polar\",\n",
    ")\n",
    "x_s = pybamm.SpatialVariable(\"x_s\", domain=[\"separator\"], coord_sys=\"cartesian\")\n",
    "x_p = pybamm.SpatialVariable(\n",
    "    \"x_p\", domain=[\"positive electrode\"], coord_sys=\"cartesian\"\n",
    ")\n",
    "\n",
    "\n",
    "geometry = {\n",
    "    \"separator\": {x_s: {\"min\": -L_s, \"max\": 0}},\n",
    "    \"positive electrode\": {x_p: {\"min\": 0, \"max\": L_p}},\n",
    "    \"positive particle\": {r: {\"min\": 0, \"max\": R_p}},\n",
    "}"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "systematic-religion",
   "metadata": {},
   "source": [
    "Both the model and geometry can now be processed by the parameter class. This replaces the parameters with the values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "southwest-reset",
   "metadata": {},
   "outputs": [],
   "source": [
    "param.process_model(model)\n",
    "param.process_geometry(geometry)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "choice-computer",
   "metadata": {},
   "source": [
    "We can now set up our mesh, choose a spatial method, and discretise our model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "occupied-danish",
   "metadata": {},
   "outputs": [],
   "source": [
    "submesh_types = {\n",
    "    \"separator\": pybamm.Uniform1DSubMesh,\n",
    "    \"positive electrode\": pybamm.Uniform1DSubMesh,\n",
    "    \"positive particle\": pybamm.Uniform1DSubMesh,\n",
    "}\n",
    "var_pts = {x_s: 10, x_p: 20, r: 30}\n",
    "mesh = pybamm.Mesh(geometry, submesh_types, var_pts)\n",
    "\n",
    "spatial_methods = {\n",
    "    \"separator\": pybamm.FiniteVolume(),\n",
    "    \"positive electrode\": pybamm.FiniteVolume(),\n",
    "    \"positive particle\": pybamm.FiniteVolume(),\n",
    "}\n",
    "disc = pybamm.Discretisation(mesh, spatial_methods)\n",
    "disc.process_model(model);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "behind-turkish",
   "metadata": {},
   "source": [
    "The model is now discretised and ready to be solved."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "creative-drunk",
   "metadata": {},
   "source": [
    "## Solving the model\n",
    "\n",
    "We can now solve the model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "fiscal-radio",
   "metadata": {},
   "outputs": [],
   "source": [
    "# solve\n",
    "solver = pybamm.IDAKLUSolver()\n",
    "t_eval = [0, 3600]\n",
    "solution = solver.solve(model, t_eval)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "worse-killer",
   "metadata": {},
   "source": [
    "and plot the results. To make the plot we will use `dynamic_plot` which automatically creates a slider plot given a `solution` and a list of variables to plot. By nesting variables in the list we can plot two variables together on the same axes. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "architectural-means",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-11-19 15:30:23,304 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for positive electrode. Using default of 1 [m].\n",
      "2021-11-19 15:30:23,328 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for separator. Using default of 1 [m].\n",
      "2021-11-19 15:30:23,367 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for positive electrode. Using default of 1 [m].\n",
      "2021-11-19 15:30:23,395 - [WARNING] processed_variable.get_spatial_scale(520): No length scale set for positive electrode. Using default of 1 [m].\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1d57bc29107d47838633a27df1b920cc",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(FloatSlider(value=0.0, description='t', max=1.0, step=0.01), Output()), _dom_classes=('w…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "<pybamm.plotting.quick_plot.QuickPlot at 0x7ff07a82d130>"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# plot\n",
    "pybamm.dynamic_plot(\n",
    "    solution,\n",
    "    [\n",
    "        \"Positive electrode potential [V]\",\n",
    "        \"Electrolyte potential [V]\",\n",
    "        \"Positive electrode interfacial current density [A.m-2]\",\n",
    "        \"Positive particle surface concentration [mol.m-3]\",\n",
    "        \"Average positive particle surface concentration [mol.m-3]\",\n",
    "        [\"Positive electrode OCP [V]\", \"Voltage [V]\"],\n",
    "    ],\n",
    ")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "abandoned-shirt",
   "metadata": {},
   "source": [
    "In the [next notebook](./6-a-simple-SEI-model.ipynb) we consider a simple model for SEI growth, and show how to correctly pose the model in non-dimensional form and then create and solve it using pybamm."
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "independent-development",
   "metadata": {},
   "source": [
    "## References\n",
    "\n",
    "The relevant papers for this notebook are:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "laden-replica",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1] Joel A. E. Andersson, Joris Gillis, Greg Horn, James B. Rawlings, and Moritz Diehl. CasADi – A software framework for nonlinear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019. doi:10.1007/s12532-018-0139-4.\n",
      "[2] Charles R. Harris, K. Jarrod Millman, Stéfan J. van der Walt, Ralf Gommers, Pauli Virtanen, David Cournapeau, Eric Wieser, Julian Taylor, Sebastian Berg, Nathaniel J. Smith, and others. Array programming with NumPy. Nature, 585(7825):357–362, 2020. doi:10.1038/s41586-020-2649-2.\n",
      "[3] Valentin Sulzer, Scott G. Marquis, Robert Timms, Martin Robinson, and S. Jon Chapman. Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1):14, 2021. doi:10.5334/jors.309.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "pybamm.print_citations()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
